/********************************************************************************
* @Author: Zhenzhou Liu
* @Date: 2024-11-18
* @Description: Cg分治练习之直线上最近点对
********************************************************************************/
#include <iostream>
#include <sstream>
#include <vector>
#include <climits>

using namespace std;

pair<pair<int, int>, int> closestPointPair(vector<int>& points, int low, int high)
{
    if (low == high)
        return {{points[low], points[low]}, INT_MAX};
    int midden = low + ((high - low) >> 1);
    pair<pair<int, int>, int> leftClosestPointPair = closestPointPair(points, low, midden);
    pair<pair<int, int>, int> rightClosestPointPair = closestPointPair(points, midden + 1, high);
    pair<pair<int, int>, int> minClosestPointPair = leftClosestPointPair.second < rightClosestPointPair.second ? leftClosestPointPair : rightClosestPointPair;
    vector<int> temp(points.begin() + low, points.begin() + high + 1);
    int i = 0, j = midden + 1 - low, k = low, iLimit = midden - low, jLimit = high - low;
    while (i <= iLimit && j <= jLimit)
    {
        if (temp[i] < temp[j])
        {
            points[k] = temp[i++];
        } else
        {
            points[k] = temp[j++];
        }

        if (k > low && points[k] - points[k - 1] < minClosestPointPair.second)
        {
            minClosestPointPair = {{points[k - 1], points[k]}, points[k] - points[k - 1]};
        }
        ++k;
    }

    while (i <= iLimit)
    {
        points[k] = temp[i++];
        if (points[k] - points[k - 1] < minClosestPointPair.second)
            minClosestPointPair = {{points[k - 1], points[k]}, points[k] - points[k - 1]};
        ++k;
    }

    while (j <= jLimit)
    {
        points[k] = temp[j++];
        if (points[k] - points[k - 1] < minClosestPointPair.second)
            minClosestPointPair = {{points[k - 1], points[k]}, points[k] - points[k - 1]};
        ++k;
    }
    return minClosestPointPair;
}

int main()
{
    string input;
    getline(cin, input);
    stringstream ss(input);
    int x;
    vector<int> points;

    while (ss >> x)
    {
        if (ss.peek() == ',')
            ss.ignore();
        points.push_back(x);
    }
    pair<pair<int, int>, int> res = closestPointPair(points, 0, points.size() - 1);
    cout << "d[" << res.first.first << "," << res.first.second << "]=" << res.second;
    return 0;
}
